/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.models;

import java.util.logging.Level;
import java.util.logging.Logger;
import main.DBmodels.User;
import main.prefExceptions.DAOException;
import main.util.DAO;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.NoneScoped;

/**
 *
 * @author Ariman
 */
@ManagedBean
@NoneScoped
public class RegUser {
    private String regName = "";
    private String regPass = "";
    private String regPassSec = "";
    private String regEmail = "";

    public String getRegEmail() {
        return regEmail;
    }

    public void setRegEmail(String regEmail) {
        this.regEmail = regEmail;
    }

    public String getRegName() {
        return regName;
    }

    public void setRegName(String regName) {
        this.regName = regName;
    }

    public String getRegPass() {
        return regPass;
    }

    public void setRegPass(String regPass) {
        this.regPass = regPass;
    }

    public String getRegPassSec() {
        return regPassSec;
    }

    public void setRegPassSec(String regPassSec) {
        this.regPassSec = regPassSec;
    }

    public String registrationAction() {        
            DAO dao = new DAO();
            User user = new User(regName, regPass, regEmail);
            try {
                dao.addUser(user);
            } catch (DAOException ex) {
                Logger.getLogger(RegUser.class.getName()).log(Level.SEVERE, null, ex);
                return "unsuccess";
            }
            return "success";
    }
}
